import express from 'express';
import { fileInterceptor, fileProcessor } from './goods.middleware';
import * as goodsRouter from './goods.controller';
import { authGuard, accessControl, userGuard } from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/goods/', goodsRouter.index);

/**
 * 获取产品
 */
router.get('/goods/:shop_id', goodsRouter.goods);

/**
 * 获取内容(按 ID)
 */
router.get('/goodsId/:postId', goodsRouter.goodsDetail);

/**
 * 按关键字查询（模糊查询）
 */
router.get('/getGoodsByKey', goodsRouter.selectByKey);

/**
 * 创建内容
 */
router.post('/goods', authGuard, goodsRouter.store);

/**
 * 更新内容
 */
router.patch('/goods/:postId', goodsRouter.update);

/**
 * 删除内容
 */
router.delete('/goods/:postId', authGuard, goodsRouter.destroy);

/**
 * 修改状态
 */
router.patch('/goodsStatus', goodsRouter.status);





/**
 * 上传文件
 */
router.post('/goodsFiles', fileInterceptor, goodsRouter.uploads);
// router.post('/goodsFiles', fileInterceptor, fileProcessor, goodsRouter.uploads);

/**
 * 删除文件
 */
router.post('/delFiles', goodsRouter.delUploads);







/**
 * 文件服务
 */
router.get('/goodsFiles/:fileId/serve', goodsRouter.serve);

/**
 * 获取文件 ID
 */
router.post('/getGoodsFilesId', goodsRouter.getFileName)

/**
 * 导出路由
 */
export default router;